﻿// Copyright (c) 2012 - 2020 Jared Zheng <jaredz at outlook dot com>
// Buddha Framework is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
//          http://license.coscl.org.cn/MulanPSL2
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PSL v2 for more details.
//
// Create : 2012-12-01 version 0.1 Jared Zheng <jaredz at outlook dot com>
// Update : 2018-12-05 version 3.1.5 Jared Zheng <jaredz at outlook dot com>

#ifndef __SERVICE_PACKET_H__
#define __SERVICE_PACKET_H__

#pragma once

#include "commonpacket.h"

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// 业务信令定义
// USRVID是内部服务器之间填写ID预留的字段, 如果没有特殊情况, 不要使用USRVID来附带参数
// 返回外网端时, UACK带有请求处理是否成功标志, ERRORD_OKAY表示成功, 其他数值由环境决定
enum PAK_EVENT_SERVICE
{
    // 维护时间
    PAKE_SERVICE_MAINTAIN = PAKE_SERVICE_BEGIN,  // CPAKSrvMaintain
    // 注册/注销
    PAKE_SERVICE_LINK,                           // CPAKSrvLink
    PAKE_SERVICE_UNLINK,                         // CPAKSrvUnlink

    PAKE_SERVICE_BOND,                           // CPAKSrvBond
    PAKE_SERVICE_LOGIN,                          // CPAKSrvLogin
    PAKE_SERVICE_SAFE,                           // CPAKSrvSafe
    PAKE_SERVICE_LOGOUT,                         // CPAKSrvLogout
    // 错误
    PAKE_SERVICE_FAULT,                          // CPAKSrvFault
    // 广播, sessionid为判断live-data, srv-id为判断条件, 扩展数据段保存server-session+routineid+其他数据, 广播改成PAKE_ROUTINE_LIVEACK
    PAKE_SERVICE_BROADCAST,                      // CPAKSrvBroadcast
    // 保留, 大于保留的为自定义事件
    PAKE_SERVICE_RESERVED  = (PAKE_SERVICE_BEGIN + 99),
    //--------------------------------------------
    PAKE_SERVICE_MAINTAINACK = PAKE_SERVICE_ACK, // CPAKSrvMaintainAck

    PAKE_SERVICE_LINKACK,                        // CPAKSrvLinkAck
    PAKE_SERVICE_UNLINKACK,                      // CPAKSrvUnlinkAck

    PAKE_SERVICE_BONDACK,
    PAKE_SERVICE_LOGINACK,                       // CPAKSrvLoginAck
    PAKE_SERVICE_SAFEACK,                        // CPAKSrvSafeAck
    PAKE_SERVICE_LOGOUTACK,                      // CPAKSrvLogoutAck

    PAKE_SERVICE_FAULTACK,                       // CPAKSrvFaultAck
    PAKE_SERVICE_BROADCASTACK,                   // CPAKSrvBroadcastAck
    // 保留, 大于保留的为自定义事件
    PAKE_SERVICE_RESERVEDACK  = (PAKE_SERVICE_ACK + 99),
};

///////////////////////////////////////////////////////////////////////////////////////////////////////////
/// 维护时间
typedef CTPAKStreamT<CTPAKSessionBase<PAKE_SERVICE_MAINTAIN, PAKT_GATE>>                  CPAKSrvMaintain;
typedef CTPAKStreamT<CTPAKSessionBase<PAKE_SERVICE_MAINTAINACK, PAKT_MASTER>>             CPAKSrvMaintainAck;

typedef CTPAKNETStreamT<CTPAKSessionBase<PAKE_SERVICE_MAINTAIN, PAKT_GATE>>               CNETSrvMaintain;
typedef CTPAKNETStreamT<CTPAKSessionBase<PAKE_SERVICE_MAINTAINACK, PAKT_MASTER>>          CNETSrvMaintainAck;

///////////////////////////////////////////////////////////////////////////////////////////////////////////
/// 注册
typedef CTPAKStreamT<CTPAKSessionBase<PAKE_SERVICE_LINK, PAKT_SERVICE>>                   CPAKSrvLink;
typedef CTPAKStreamT<CTPAKSessionBase<PAKE_SERVICE_LINKACK, PAKT_MASTER>>                 CPAKSrvLinkAck;

typedef CTPAKNETStreamT<CTPAKSessionBase<PAKE_SERVICE_LINK, PAKT_SERVICE>>                CNETSrvLink;
typedef CTPAKNETStreamT<CTPAKSessionBase<PAKE_SERVICE_LINKACK, PAKT_MASTER>>              CNETSrvLinkAck;

///////////////////////////////////////////////////////////////////////////////////////////////////////////
/// 注销
typedef CTPAKStreamT<CTPAKSessionBase<PAKE_SERVICE_UNLINK, PAKT_SERVICE>>                 CPAKSrvUnlink;
typedef CTPAKStreamT<CTPAKSessionBase<PAKE_SERVICE_UNLINKACK, PAKT_MASTER>>               CPAKSrvUnlinkAck;

typedef CTPAKNETStreamT<CTPAKSessionBase<PAKE_SERVICE_UNLINK, PAKT_SERVICE>>              CNETSrvUnlink;
typedef CTPAKNETStreamT<CTPAKSessionBase<PAKE_SERVICE_UNLINKACK, PAKT_MASTER>>            CNETSrvUnlinkAck;

///////////////////////////////////////////////////////////////////////////////////////////////////////////
/// 连接
typedef CTPAKStreamT<CTPAKSessionBase<PAKE_SERVICE_BOND, PAKT_EXTERNAL_MASTER>>           CPAKSrvBond;
typedef CTPAKStreamT<CTPAKSessionBase<PAKE_SERVICE_BONDACK, PAKT_GATE>>                   CPAKSrvBondAck;

typedef CTPAKNETStreamT<CTPAKSessionBase<PAKE_SERVICE_BOND, PAKT_EXTERNAL_MASTER>>        CNETSrvBond;
typedef CTPAKNETStreamT<CTPAKSessionBase<PAKE_SERVICE_BONDACK, PAKT_GATE>>                CNETSrvBondAck;

///////////////////////////////////////////////////////////////////////////////////////////////////////////
/// 登陆
typedef CTPAKStreamT<CTPAKSessionBase<PAKE_SERVICE_LOGIN, PAKT_EXTERNAL_MASTER>>          CPAKSrvLogin;
typedef CTPAKStreamT<CTPAKSessionBase<PAKE_SERVICE_LOGINACK, PAKT_GATE>>                  CPAKSrvLoginAck;

typedef CTPAKNETStreamT<CTPAKSessionBase<PAKE_SERVICE_LOGIN, PAKT_EXTERNAL_MASTER>>       CNETSrvLogin;
typedef CTPAKNETStreamT<CTPAKSessionBase<PAKE_SERVICE_LOGINACK, PAKT_GATE>>               CNETSrvLoginAck;

///////////////////////////////////////////////////////////////////////////////////////////////////////////
/// 安全验证
typedef CTPAKStreamT<CTPAKSessionBase<PAKE_SERVICE_SAFE, PAKT_EXTERNAL_MASTER>>           CPAKSrvSafe;
typedef CTPAKStreamT<CTPAKSessionBase<PAKE_SERVICE_SAFEACK, PAKT_GATE>>                   CPAKSrvSafeAck;

typedef CTPAKNETStreamT<CTPAKSessionBase<PAKE_SERVICE_SAFE, PAKT_EXTERNAL_MASTER>>        CNETSrvSafe;
typedef CTPAKNETStreamT<CTPAKSessionBase<PAKE_SERVICE_SAFEACK, PAKT_GATE>>                CNETSrvSafeAck;

///////////////////////////////////////////////////////////////////////////////////////////////////////////
/// 登出
typedef CTPAKStreamT<CTPAKSessionBase<PAKE_SERVICE_LOGOUT, PAKT_EXTERNAL_MASTER>>         CPAKSrvLogout;
typedef CTPAKStreamT<CTPAKSessionBase<PAKE_SERVICE_LOGOUTACK, PAKT_GATE>>                 CPAKSrvLogoutAck;

typedef CTPAKNETStreamT<CTPAKSessionBase<PAKE_SERVICE_LOGOUT, PAKT_EXTERNAL_MASTER>>      CNETSrvLogout;
typedef CTPAKNETStreamT<CTPAKSessionBase<PAKE_SERVICE_LOGOUTACK, PAKT_GATE>>              CNETSrvLogoutAck;

///////////////////////////////////////////////////////////////////////////////////////////////////////////
/// 错误
typedef CTPAKStreamT<CTPAKSessionBase<PAKE_SERVICE_FAULT, PAKT_EXTERNAL_MASTER>>          CPAKSrvFault;
typedef CTPAKStreamT<CTPAKSessionBase<PAKE_SERVICE_FAULTACK, PAKT_GATE>>                  CPAKSrvFaultAck;

typedef CTPAKNETStreamT<CTPAKSessionBase<PAKE_SERVICE_FAULT, PAKT_EXTERNAL_MASTER>>       CNETSrvFault;
typedef CTPAKNETStreamT<CTPAKSessionBase<PAKE_SERVICE_FAULTACK, PAKT_GATE>>               CNETSrvFaultAck;

///////////////////////////////////////////////////////////////////////////////////////////////////////////
/// 广播
typedef CTPAKStreamT<CTPAKSessionBase<PAKE_SERVICE_BROADCAST, PAKT_EXTERNAL_MASTER>>      CPAKSrvBroadcast;
typedef CTPAKStreamT<CTPAKSessionBase<PAKE_SERVICE_BROADCASTACK, PAKT_SERVICE>>           CPAKSrvBroadcastAck;

typedef CTPAKNETStreamT<CTPAKSessionBase<PAKE_SERVICE_BROADCAST, PAKT_EXTERNAL_MASTER>>   CNETSrvBroadcast;
typedef CTPAKNETStreamT<CTPAKSessionBase<PAKE_SERVICE_BROADCASTACK, PAKT_SERVICE>>        CNETSrvBroadcastAck;

///////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "servicepacket.inl"

#endif // __SERVICE_PACKET_H__
